<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <button id="btn">按钮</button>
    <!-- script标签发送请求之后,会将响应主体中的内容自动放到script标签的子节点的位置执行 -->
    <!-- <script src="http://localhost:5000/a">
      //'响应了'
      // const str = "响应了"
    </script> -->
    <script>
      const btn = document.getElementById('btn')

      function fn(data) {
        console.log(data)
      }

      btn.onclick = function () {
        // 创建script标签
        const script = document.createElement('script')
        script.src = 'http://localhost:5000/a?callback=fn'
        // 需要把script标签添加到dom树上,才会被浏览器解析,才会发送请求
        document.body.appendChild(script)
      }
    </script>
    <!-- <script>
      fn('响应了')
      fn(a,b,c)
    </script> -->
  </body>
</html>
